package tw.com.todo.serivce;



import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import tw.com.todo.api.And002Serivce;
import tw.com.todo.common.AndToDoCommon;
import tw.com.todo.daoImp.And002DAOImp;
import tw.com.todo.db.dto.And002DTO;

import tw.com.todo.db.sample.comm.And002DBCommon;
import tw.com.todo.db.sample.comm.DBCommon;

public class And002SerivceImp implements And002Serivce,And002DBCommon,AndToDoCommon,DBCommon{
	private And002DAOImp dao=new And002DAOImp();
	public void addTask(SQLiteDatabase data, And002DTO dto) throws Exception {
		
	}

	public void updataTask(SQLiteDatabase data, And002DTO dto)  {
		boolean sucessfull=false;
		try {
			sucessfull=dao.updata(dto, data);
		} catch (Exception e) {			
			e.printStackTrace();
		}
	
	}

	public void deleteTask(SQLiteDatabase data, And002DTO dto)  {		
	
		boolean sucessfull=false;
		try {
			sucessfull=dao.remove(dto, data);
			
		} catch (Exception e) {			
			e.printStackTrace();
		}
		
		
	}

	public Cursor getTaskAllToday(SQLiteDatabase data)  {	
		
		try {
			return dao.query( null, data);
		} catch (Exception e) {			
			e.printStackTrace();
		}
		
		
		return null;
	}

	public void addImmTaskToday(SQLiteDatabase data, And002DTO dto)  {		
		try {
			dao.addToday(dto, data);
		} catch (Exception e) {			
			e.printStackTrace();
		}		
	}
	
	public void addImmTaskTorrow(SQLiteDatabase data, And002DTO dto)  {		
		try {
			dao.addTorrow(dto, data);
		} catch (Exception e) {			
			e.printStackTrace();
		}		
	}

	public Cursor getTaskWithConditon(SQLiteDatabase data, And002DTO dto) {
		Cursor c=null;
	
		try {
			c= dao.queryWithCond(dto, data);
			
			
		} catch (Exception e) {			
			e.printStackTrace();
		}
		
		return c;
	}

	public Cursor getTasOnToday(SQLiteDatabase data) {
		
		try {
			return dao.queryToday(data);
		} catch (Exception e) {			
			e.printStackTrace();
		}
		return null;
	}

	public Cursor getTaskOnTorrow(SQLiteDatabase data) {
	
		try {
			return dao.queryTor( data);
		} catch (Exception e) {			
			e.printStackTrace();
		}
		return null;
	}

	public void finishTask(SQLiteDatabase data, And002DTO dto) {
		boolean sucessfull=false;
		dto.setIsFinish("1");
		try {
			sucessfull=dao.updata(dto, data);
		} catch (Exception e) {			
			e.printStackTrace();
		}
		
	}
	

}
